﻿@inherits EntitesGridModel<Entity.ApiSecret>

<EntitiesGrid Items="@Secrets" TableClass="table table-hover" Context="secret">
    <TableHeader>
        <th scope="col">
            <SortableHeader Property="Type"
                            Text="@Localizer["type"]"
                            GridState="GridState" />
        </th>
        <th scope="col">
            <SortableHeader Property="Value"
                            Text="@Localizer["value"]"
                            GridState="GridState" />
        </th>
        <th scope="col">
            <SortableHeader Property="Description"
                            Text="@Localizer["description"]"
                            GridState="GridState" />
        </th>
        <th scope="col">
            <SortableHeader Property="Expiration"
                            Text="@Localizer["expiration"]"
                            GridState="GridState" />
        </th>
        <th></th>
    </TableHeader>
    <RowTemplate>
        @if (secret.Id != null)
        {
            <td>
                <div class="col-form-label">
                    @secret.Type
                </div>
            </td>
            <td>
                <input type="password" readonly class="form-control-plaintext" value="@secret.Value" />
            </td>
        }
        else
        {
            <td>
                <AuthorizeDropDownButton CssSubClass="btn-secondary" @bind-Value="@secret.Type" Values="@SecretTypes.Values" />
            </td>
            <td class="input-group">
                <AuthorizeText Placeholder="value" @bind-Value="@secret.Value" MaxLength="4000" />
                @if (secret.Type == SecretTypes.SharedSecret)
                {
                    <button class="btn btn-secondary input-group-append" type="button" @onclick="@(() => GenerateSecret(secret))"><span class="oi oi-loop-circular"></span></button>
                }

            </td>
        }
        <td>
            <AuthorizeText Placeholder="description" @bind-Value="@secret.Description" MaxLength="1000" />
        </td>
        <td>
            <AuthorizeDate @bind-Value="@secret.Expiration" />
        </td>
        <td>
            <AuthorizeButton Type="button" CssSubClass="btn-primary" Clicked="() => OnDeleteEntityClicked(secret)">
                <span class="oi oi-trash"></span>
            </AuthorizeButton>
        </td>
    </RowTemplate>
</EntitiesGrid>